<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AddColumnToDyUser extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('dy_user');
        $table->addColumn('open_id','string',['limit'=>50,'after'=>'user_id'])
            ->addColumn('union_id','string',['limit'=>50,'after'=>'open_id','default'=>'','comment'=>'当前开发者账号下的唯一标识'])
            ->addColumn('gender','boolean',['limit'=>1,'after'=>'works','default'=>0,'comment'=>'性别 0未知 1男 2女'])
            ->addColumn('country','string',['limit'=>100,'after'=>'gender','default'=>'','comment'=>'国家'])
            ->addColumn('province','string',['limit'=>100,'after'=>'country','default'=>'','comment'=>'省'])
            ->addColumn('city','string',['limit'=>100,'after'=>'province','default'=>'','comment'=>'城市'])
            ->addColumn('access_token','string',['limit'=>80,'after'=>'city','default'=>'','comment'=>'access_token'])
            ->addColumn('expires_in','biginteger',['limit'=>20,'after'=>'access_token','default'=>0,'comment'=>'access_token过期时间'])
            ->save();
    }
}
